using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using RAG.Infrastructure.Data;

namespace RAG.Infrastructure;

/// <summary>
/// DbContext 工厂类，用于设计时创建 DbContext 实例
/// 主要用于 EF Core 迁移和工具支持
/// </summary>
public class ApplicationDbContextFactory : IDesignTimeDbContextFactory<RagAIDbContext>
{
    public RagAIDbContext CreateDbContext(string[] args)
    {
        var optionsBuilder = new DbContextOptionsBuilder<RagAIDbContext>();

        // 使用默认连接字符串用于迁移，启用pgvector扩展
        optionsBuilder.UseNpgsql("Host=njy22.cn;Port=5432;Database=RagAI;Username=postgres;Password=postgreSQL@njy22.cn;",
            options => options.UseVector());

        return new RagAIDbContext(optionsBuilder.Options);
    }
}
